package com.qianxx.component.activity.recycleview.ex_refresh_view;

import android.os.Bundle;
import android.support.v7.widget.LinearLayoutManager;

import com.qianxx.component.R;
import com.qianxx.component.activity.base.BaseActivity;
import com.qianxx.viewlibrary.recyclerview.refreshview.ExRefreshView;
import com.qianxx.viewlibrary.recyclerview.refreshview.RefreshViewListener;
import com.qianxx.viewlibrary.recyclerview.refreshview.adapter.OnItemMoveListener;
import com.qianxx.viewlibrary.recyclerview.refreshview.adapter.SuperAdapter;

import java.util.ArrayList;
import java.util.List;

import butterknife.BindView;
import butterknife.ButterKnife;

public class ExRefreshViewActivity extends BaseActivity implements RefreshViewListener, OnItemMoveListener {

    @BindView(R.id.erv)
    ExRefreshView erv;
    ExRefreshViewAdapter adapter;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_ex_refresh_view);
        ButterKnife.bind(this);

        adapter = new ExRefreshViewAdapter(this);
        adapter.setOnItemMoveListener(erv.getRecyclerView(), this);
        erv.setLayoutManager(new LinearLayoutManager(this));
        erv.setRefreshListener(this);
        erv.setAdapter(adapter);
        adapter.setAll(initData());
    }

    @Override
    public String setTitle() {
        return "ExRefreshView";
    }

    /**
     * 下拉刷新
     */
    @Override
    public void onRefresh() {
        erv.setRefreshing(false);
    }

    /**
     * 上拉加载
     */
    @Override
    public void onLoadMore() {
        erv.setLoadingMore(false);
    }

    private List<String> initData() {
        List<String> list = new ArrayList<>();
        list.add("阿巴斯");
        list.add("奥迪");
        list.add("阿斯顿马丁");
        list.add("宝马");
        list.add("保时捷");
        list.add("奔驰");
        list.add("标致");
        list.add("别克");
        list.add("宾利");
        list.add("比亚迪");
        list.add("长安");
        list.add("大众");
        list.add("福特");
        list.add("海马");
        list.add("皇冠");
        list.add("江淮");
        list.add("捷豹");
        list.add("凯迪拉克");
        list.add("兰博基尼");
        list.add("劳斯莱斯");
        list.add("雷克萨斯");
        list.add("雷诺");
        list.add("力帆");
        list.add("路虎");
        list.add("迈巴赫");
        list.add("马自达");
        list.add("Mini");
        list.add("Nissan");
        list.add("奇瑞");
        list.add("起亚");
        list.add("现代");
        list.add("雪佛兰");
        list.add("雪铁龙");
        list.add("英菲尼迪");
        list.add("中兴");
        return list;
    }

    /**
     * 元素滑动移除事件
     *
     * @param adapter
     * @param position
     * @param o
     */
    @Override
    public void onRemove(SuperAdapter adapter, int position, Object o) {

    }

    /**
     * 元素滑动交换事件
     *
     * @param adapter
     * @param src
     * @param target
     */
    @Override
    public void onExchange(SuperAdapter adapter, Object src, Object target) {

    }
}
